package com.example.building_material_mannager.controller;

import com.example.building_material_mannager.entity.Protype;
import com.example.building_material_mannager.service.ProtypeService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

@Controller
@RequestMapping("protype")
public class ProtypeController {
    @Resource
    ProtypeService protypeService;
    @ResponseBody
    @RequestMapping("show")
    public  List<Protype> showProtype(Protype protype){
        List<Protype> protypes = protypeService.showProtype(protype);
        return protypes;
    }
    //增加
    @ResponseBody
    @RequestMapping("add")
    public void addProtype(Protype protype){

        boolean re = protypeService.addProtype(protype);
        System.out.println(re);
    }

    //刪除
    @ResponseBody
    @RequestMapping("del")
    public void delProtype(Integer ptid){

        boolean re = protypeService.delProtype(ptid);
        System.out.println(re);
    }
    //更新
    @ResponseBody
    @RequestMapping("up")
    public void upProtype(Protype protype){
        System.out.println(protype);
        boolean re = protypeService.upProtype(protype);
        System.out.println(re);
    }
}
